﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Qiang.Topology.Geometries;

namespace Qiang.Data
{
    [Serializable]
    public abstract class Shape:IShape
    {

        #region 初始化

        /// <summary>
        /// 
        /// </summary>
        public Shape()
        {
           
        }

        #endregion


        #region 属性

        string _id;

        public string ID
        {
            get { return _id; }
            set { _id = value; }
        }
      
        /// <summary>
        /// 范围
        /// </summary>
        public IExtent Extent
        {
            get 
            {
                return ComputeExtent();                
            }
        }


        /// <summary>
        /// 坐标集合.
        /// </summary>
        public IList<Coordinate> Coordinates
        {
            get { return ComputeCoordinates(); }
        }

       
        /// <summary>
        /// 图形类型
        /// </summary>
        public virtual ShapeType ShapeType
        {
            get { return ShapeType.UnDefined; }           
        }


        private IDataset _parentDataset;

        /// <summary>
        /// 所属数据集
        /// </summary>
        public IDataset ParentDataset
        {
            get
            {
                return _parentDataset;
            }
            set 
            {
                _parentDataset = value;
            }
        }


        #endregion

        
        #region 虚方法

        /// <summary>
        /// 获取图形的范围
        /// </summary>
        /// <returns></returns>
        protected virtual IExtent ComputeExtent()
        {
            IExtent ext = new Extent();
            return ext;
        }


        /// <summary>
        /// 计算坐标集合.
        /// </summary>
        /// <returns></returns>
        protected virtual IList<Coordinate> ComputeCoordinates()
        {
            return null;
        }




        #endregion


        public abstract IGeometry ToGeometry();


        public virtual object Clone()
        {
            return MemberwiseClone();
        }

    }
}
